<@sp.pagehead shiroUserHelper.getCurrentShiroUser().parentSources />
<div class="panel panel-inverse" data-sortable-id="form-validation-1">
    <div class="panel-heading">
        <h4 class="panel-title">修改班级</h4>
    </div>
    <div class="panel-body">
        <form id="clazzAddForm" name="clazzAddForm" action="" method="post" class="form-horizontal form-bordered">
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">班级名称</label>
                <div class="col-md-7 col-sm-7">
                    <input type="text" id="id" name="id" value="${clazz.id}" style="display: none">
                    <input type="text" id="clsName" class="form-control" name="clsName" value="${clazz.clsName}"
                           placeholder="班级名称 2-10位" rangelength="2,10" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">班级宣言</label>
                <div class="col-md-7 col-sm-7">
                    <textarea class="form-control" placeholder="请填写班级宣言.... 1-100位" rows="5" name="clsContent"
                              id="clsContent"
                              rangelength="1,100">${clazz.clsContent}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3"></label>
                <div class="col-md-7 col-sm-7">
                    <button type="button" id="clazzSubmitButton" class="btn btn-sm btn-success">修改</button>
                    <button type="button" class="btn btn-sm btn-default"
                            onclick="getData('${rc.contextPath}/clazz/query','${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}')">
                        返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">
    $(function () {
        $('#clazzSubmitButton').click(function () {
            $('#clazzAddForm').submit();
        })
        $('#clazzAddForm').validate({
            rules: {
                name: {
                    byteRangeLength: [2, 20]
                }
            },
            messages: {
                clazzName: {
                    rangelength: "长度为2-20位"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByForm('${rc.contextPath}/clazz/edit', '${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}', 'clazzAddForm');
            }
        })
    })
</script>

